package info.sean.main;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Strings;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import static org.apache.commons.lang3.time.DateUtils.truncate;

/**
 * 请求的数据可以转换为json格式
 */
public class TestJson {
    public static void main(String[] args) throws ParseException {
		String req = "memberNo=d31ca5f30f9e5b90616df3999637e6ea,loanAmount=2160.000000,currentDate=Fri Jun 18 00:00:00 GMT+08:00 2021,productMirrorNo=0883d8cdafde1d56103d62c8d5b20407,productPricingMirrorNo=2a33030a54744ce5b399d1dc8b09d10b,currentStage=1,totalStage=9,allDebitList=[DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Sat May 28 00:00:00 GMT+08:00 2022,dueDate=Tue Jun 28 00:00:00 GMT+08:00 2022,mustPayDate=Tue Jun 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Jul 01 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=118f73ff9f954f8c95f7f570d5b17b5d,currentStage=1,mustPayPrincipal=234.060000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=13.500000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.92,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.14,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Wed Jun 29 00:00:00 GMT+08:00 2022,dueDate=Thu Jul 28 00:00:00 GMT+08:00 2022,mustPayDate=Thu Jul 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Sun Jul 31 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=54d9a6577c7747468c6f6aa27630ee26,currentStage=2,mustPayPrincipal=235.520000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=12.040000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.79,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.27,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Fri Jul 29 00:00:00 GMT+08:00 2022,dueDate=Sun Aug 28 00:00:00 GMT+08:00 2022,mustPayDate=Sun Aug 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Wed Aug 31 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=600b150de63f43388251b55429a2cb37,currentStage=3,mustPayPrincipal=236.990000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=10.570000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.72,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.34,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Mon Aug 29 00:00:00 GMT+08:00 2022,dueDate=Wed Sep 28 00:00:00 GMT+08:00 2022,mustPayDate=Wed Sep 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Sat Oct 01 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=65a6b663bca4458491abfe7110a6006f,currentStage=4,mustPayPrincipal=238.480000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=9.080000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.62,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.44,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Thu Sep 29 00:00:00 GMT+08:00 2022,dueDate=Fri Oct 28 00:00:00 GMT+08:00 2022,mustPayDate=Fri Oct 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Mon Oct 31 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=07dd9afbc692404681c90dbe49a5c5b6,currentStage=5,mustPayPrincipal=239.970000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=7.590000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.5,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.56,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Sat Oct 29 00:00:00 GMT+08:00 2022,dueDate=Mon Nov 28 00:00:00 GMT+08:00 2022,mustPayDate=Mon Nov 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Thu Dec 01 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=5e20f5e00b3f4f1c834f28b278a26e1a,currentStage=6,mustPayPrincipal=241.470000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=6.090000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.41,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.65,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Tue Nov 29 00:00:00 GMT+08:00 2022,dueDate=Wed Dec 28 00:00:00 GMT+08:00 2022,mustPayDate=Wed Dec 28 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Sat Dec 31 00:00:00 GMT+08:00 2022,overdueDay=0,debitNo=55fb896657c6421d8b02ce2c7716b938,currentStage=7,mustPayPrincipal=242.980000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=4.580000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.3,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.76,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Thu Dec 29 00:00:00 GMT+08:00 2022,dueDate=Sat Jan 28 00:00:00 GMT+08:00 2023,mustPayDate=Sat Jan 28 00:00:00 GMT+08:00 2023,actualPayDate=<null>,graceDate=Tue Jan 31 00:00:00 GMT+08:00 2023,overdueDay=0,debitNo=79d88c8633d94dfdbd01736e8aa88b04,currentStage=8,mustPayPrincipal=244.490000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=3.070000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.21,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.85,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>], DebitDetailBaseModel[version=0,lastDebitMemberNo=d31ca5f30f9e5b90616df3999637e6ea,lastDebitMemberType=2,debitStatus=1,valueDate=Sun Jan 29 00:00:00 GMT+08:00 2023,dueDate=Tue Feb 28 00:00:00 GMT+08:00 2023,mustPayDate=Tue Feb 28 00:00:00 GMT+08:00 2023,actualPayDate=<null>,graceDate=Fri Mar 03 00:00:00 GMT+08:00 2023,overdueDay=0,debitNo=50f9ac04283040f586ac3681e6f2c7ad,currentStage=9,mustPayPrincipal=246.040000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=1.540000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=GUARANTEE_FEE,mustPayAmount=0.1,actualPayAmount=0,derateAmount=0,feeName=<null>], FeeModel[feeCode=SERVICE_FEE,mustPayAmount=16.94,actualPayAmount=0,derateAmount=0,feeName=<null>]],remainTotalPrincipal=<null>]],debitFeeDiscountList=<null>,clearingFormulaNo=766bdbe4294c42a2bee62d06d15bc746,refRepayDebitModelList=[RefRepayModel[capitalCode=C5010,currentStage=1,actualPayPrincipal=352.77,actualPayInterest=6.09,actualPayPenaltyInterest=0.00,repayDate=Fri Jun 18 00:00:00 GMT+08:00 2021]],preSettleRateType=0,iRRMaxAmount=<null>";
//		String req ="currentStage=1,remainRightOwnerNo=f0a9f325cd83428f91de6d54d3fe655a,capitalList=[CapitalDto[capitalMemberNo=26fc0ccfd69b4c81be282d6006f9c2ff,capitalMirrorNo=98fdda8be8364f51847dcc638d90bdd8,capitalPricingMirrorNo=bd09ef58bcc44671a09e94132515c5b1,investmentRatio=1.000000,investmentAmount=2000.000000], CapitalDto[capitalMemberNo=f0a9f325cd83428f91de6d54d3fe655a,capitalMirrorNo=c5ee3ab87492f02eb48c416532b1cc49,capitalPricingMirrorNo=27528d3d7eefa12599f1604bea40c811,investmentRatio=0.000000,investmentAmount=0.000000]],compensator=CompensatorDto[capitalMemberNo=08476f844d354af9ae965f9f19b142d0,capitalMirrorNo=11d05b0dde33c6ca00253b752cc120fb,capitalPricingMirrorNo=bec0ac99565e43598d79c2858cc0da14],clearingFormulaNo=2996400e69df4b758b2160856c910270,repurchaseStage=2,costRightStages=<null>,excludeRepurchasedFeeList=false,allDebitList=[DebitDetailBaseModel[lastDebitMemberNo=b33b3a617c3a3a20f687d411e71eebf5,lastDebitMemberType=2,debitStatus=1,debitNo=e1c73b79f734460b8ec4b8db076a8101,currentStage=2,mustPayPrincipal=666.670000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.600000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Sun Jan 02 00:00:00 GMT+08:00 2022,dueDate=Tue Feb 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Feb 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Feb 04 00:00:00 GMT+08:00 2022,overdueDay=0], DebitDetailBaseModel[lastDebitMemberNo=b33b3a617c3a3a20f687d411e71eebf5,lastDebitMemberType=2,debitStatus=1,debitNo=cf5ee5232c344ecda5406cb48cbf0f08,currentStage=3,mustPayPrincipal=666.660000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.610000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remain";
//        String req= "currentDate=Mon Dec 06 00:00:00 GMT+08:00 2021,currentStage=1,remainRightOwnerNo=f0a9f325cd83428f91de6d54d3fe655a,capitalList=[CapitalDto[capitalMemberNo=26fc0ccfd69b4c81be282d6006f9c2ff,capitalMirrorNo=98fdda8be8364f51847dcc638d90bdd8,capitalPricingMirrorNo=bd09ef58bcc44671a09e94132515c5b1,investmentRatio=1.000000,investmentAmount=2000.000000], CapitalDto[capitalMemberNo=f0a9f325cd83428f91de6d54d3fe655a,capitalMirrorNo=c5ee3ab87492f02eb48c416532b1cc49,capitalPricingMirrorNo=27528d3d7eefa12599f1604bea40c811,investmentRatio=0.000000,investmentAmount=0.000000]],compensator=CompensatorDto[capitalMemberNo=08476f844d354af9ae965f9f19b142d0,capitalMirrorNo=11d05b0dde33c6ca00253b752cc120fb,capitalPricingMirrorNo=bec0ac99565e43598d79c2858cc0da14],clearingFormulaNo=2996400e69df4b758b2160856c910270,repurchaseStage=2,costRightStages=<null>,excludeRepurchasedFeeList=false,allDebitList=[DebitDetailBaseModel[lastDebitMemberNo=b33b3a617c3a3a20f687d411e71eebf5,lastDebitMemberType=2,debitStatus=1,debitNo=e1c73b79f734460b8ec4b8db076a8101,currentStage=2,mustPayPrincipal=666.670000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.600000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Sun Jan 02 00:00:00 GMT+08:00 2022,dueDate=Tue Feb 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Feb 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Feb 04 00:00:00 GMT+08:00 2022,overdueDay=0], DebitDetailBaseModel[lastDebitMemberNo=b33b3a617c3a3a20f687d411e71eebf5,lastDebitMemberType=2,debitStatus=1,debitNo=cf5ee5232c344ecda5406cb48cbf0f08,currentStage=3,mustPayPrincipal=666.660000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.610000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Wed Feb 02 00:00:00 GMT+08:00 2022,dueDate=Tue Mar 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Mar 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Mar 04 00:00:00 GMT+08:00 2022,overdueDay=0]],allRightList=[RightDetailBaseModel[lastRightMemberNo=26fc0ccfd69b4c81be282d6006f9c2ff,lastRightMemberType=1,rightStatus=1,compensationType=1,compensationDate=Tue Feb 01 00:00:00 GMT+08:00 2022,rightNo=530e4c54e98c4ba08d6b0b52ffcae8b3,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,repurchaseCost=0.000000,currentStage=2,mustPayPrincipal=666.670000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.600000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Sun Jan 02 00:00:00 GMT+08:00 2022,dueDate=Tue Feb 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Feb 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Tue Feb 01 00:00:00 GMT+08:00 2022,overdueDay=0], RightDetailBaseModel[lastRightMemberNo=26fc0ccfd69b4c81be282d6006f9c2ff,lastRightMemberType=1,rightStatus=1,compensationType=1,compensationDate=Tue Mar 01 00:00:00 GMT+08:00 2022,rightNo=6385988f8995470fad800400a4dd42cd,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,repurchaseCost=0.000000,currentStage=3,mustPayPrincipal=666.660000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=25.610000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Wed Feb 02 00:00:00 GMT+08:00 2022,dueDate=Tue Mar 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Mar 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Tue Mar 01 00:00:00 GMT+08:00 2022,overdueDay=0], RightDetailBaseModel[lastRightMemberNo=f0a9f325cd83428f91de6d54d3fe655a,lastRightMemberType=1,rightStatus=1,compensationType=0,compensationDate=<null>,rightNo=d4aeb84f857b4d53ab35fc978cdf655b,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,repurchaseCost=0.000000,currentStage=2,mustPayPrincipal=0.000000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=0.000000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Sun Jan 02 00:00:00 GMT+08:00 2022,dueDate=Tue Feb 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Feb 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Feb 04 00:00:00 GMT+08:00 2022,overdueDay=0], RightDetailBaseModel[lastRightMemberNo=f0a9f325cd83428f91de6d54d3fe655a,lastRightMemberType=1,rightStatus=1,compensationType=0,compensationDate=<null>,rightNo=a5693c99a7f04a5da72ea28ec2af48cd,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,repurchaseCost=0.000000,currentStage=3,mustPayPrincipal=0.000000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=0.000000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[],remainTotalPrincipal=<null>,version=0,valueDate=Wed Feb 02 00:00:00 GMT+08:00 2022,dueDate=Tue Mar 01 00:00:00 GMT+08:00 2022,mustPayDate=Tue Mar 01 00:00:00 GMT+08:00 2022,actualPayDate=<null>,graceDate=Fri Mar 04 00:00:00 GMT+08:00 2022,overdueDay=0]],refRepayModelList=[RefRepayModel[capitalCode=C5600,currentStage=2,actualPayPrincipal=1333.330000,actualPayInterest=25.600000,actualPayPenaltyInterest=0,repayDate=Mon Dec 06 00:00:00 GMT+08:00 2021]],costRightValueType=1";
        System.out.println("[" + getObject(req) + "]");
        System.out.println();
    }

    public static String getObject(String req) throws ParseException {
        Map<String,Object> object = new HashMap<>();
        String key = null,value = null;
        int index = 0 ;
        do{
            if(req.charAt(index) == '='){
                key = req.substring(0,index);
                if(req.charAt(index+1) == '['){
                    String valueContent = getClosebracketsContent(req);
                    value = valueContent;
                    List<Object> list = new ArrayList<>();
                    do{
                        String str = getClosebracketsContent(value);
                        value = value.substring(value.indexOf(str)+str.length(),value.length());
                        if(Strings.isNullOrEmpty(str)){
                            if(value.contains(",") && ! value.contains("{") && ! value.contains("}")){
                                list.addAll(Arrays.asList(value.split(",")));
                            }
                            break;
                        }
                        list.add(JSON.parseObject(getObject(str)));
                    }while (true);
                    object.put(key,list);

                    if(StringUtils.isEmpty(valueContent)){
                        if(index + 1 + 3 >= req.length()){
                            req = req.substring(index + 3);
                        }else{
                            req = req.substring(index + 1 + 3);
                        }
                    }else{
                        req = req.substring(req.indexOf(valueContent) + valueContent.length() + 1);
                    }
                    index =0;
                    key = null;
                    value = null;
                }else{
                    req = req.substring(index + 1);
                    if(req.indexOf(",") > 0 && req.substring(0,req.indexOf(",")).contains("[")){
                        String valueContent = getClosebracketsContent(req);
                        if(Strings.isNullOrEmpty(valueContent)){
                            break;
                        }

                        object.put(key,JSON.parseObject(getObject(valueContent)));
                        req = req.substring(req.indexOf(valueContent) + valueContent.length() + 1);
                        index =0;
                        key = null;
                        value = null;
                    }else{
                        index = 0;
                    }
                }
                continue;
            }

            if(req.charAt(index) == ',' || index == req.length() -1 || ( req.charAt(index) == ']' &&  req.charAt(index) == ',')){
                value = req.substring(0,index == req.length() -1 ? index + 1 : index);
                value = value.trim().equals("<null>")?null:value.trim();
                if(value != null && (value.contains("GMT+08:00") || (value.contains("CST")))){
                    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
                    object.put(key, sdf.parse(value));
                }else{
                    object.put(key,value);
                }

                req = req.substring(index +1);
                index = 0;
                key = null;
                value = null;
                continue;
            }

            index++;
        }while (index < req.length());
        object.remove(null);
        return JSON.toJSONString(object);
    }

//	public static void main1(String[] args) {
//
//		String req = "PreSettleDebitAndRightRequest[memberNo=1a16a209acf711e9a3aefa163fdb847b,currentDate=Sat Mar 02 00:00:00 CST 2030,loanAmount=3000.000000,productMirrorNo=a8409c1cd0b74cc8b86da4922d31b54c,productPricingMirrorNo=af1905daf1ef2b717f0f721d13e1b97d,capitalList=[CapitalDto[capitalMemberNo=5a72a945a48a11e99c8e1ac1b181ecad,capitalMirrorNo=660cae4cec8ddfee59f24d898257a283,capitalPricingMirrorNo=cee066b8e0525c586a67f3481b1557a5,investmentRatio=1.000000], CapitalDto[capitalMemberNo=4bfbe1bd2fee4513a0aa3df699fb679c,capitalMirrorNo=e87260ee571b4d37a04f7ca227ab714a,capitalPricingMirrorNo=d0fefab9f42d4ae1bd0c5e0a95e84aff,investmentRatio=0.000000]],remainRightOwnerNo=4bfbe1bd2fee4513a0aa3df699fb679c,clearingFormulaNo=a93940ecd4e2423cb76edbdc068c457a,currentStage=2,rightSettleStage=1,rightSettleDate=<null>,allRightList=[RightDetailBaseModel[version=1,lastRightMemberNo=5a72a945a48a11e99c8e1ac1b181ecad,lastRightMemberType=1,rightStatus=2,valueDate=Sun Dec 23 00:00:00 CST 2029,dueDate=Wed Jan 23 00:00:00 CST 2030,mustPayDate=Wed Jan 23 00:00:00 CST 2030,actualPayDate=Sat Aug 03 18:02:57 CST 2019,graceDate=Sat Jan 26 00:00:00 CST 2030,overdueDay=0,compensationType=1,compensationDate=Wed Jan 23 00:00:00 CST 2030,rightNo=25e54ce71eea4e3188fa2a3a95146652,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,currentStage=1,mustPayPrincipal=991.710000,actualPayPrincipal=991.710000,deratePrincipal=0.000000,mustPayInterest=25.830000,actualPayInterest=25.830000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[]], RightDetailBaseModel[version=0,lastRightMemberNo=5a72a945a48a11e99c8e1ac1b181ecad,lastRightMemberType=1,rightStatus=1,valueDate=Wed Jan 23 00:00:00 CST 2030,dueDate=Sat Feb 23 00:00:00 CST 2030,mustPayDate=Sat Feb 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Tue Feb 26 00:00:00 CST 2030,overdueDay=0,compensationType=1,compensationDate=Sat Feb 23 00:00:00 CST 2030,rightNo=c5e58901f8e24eeba52453851c6014e6,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,currentStage=2,mustPayPrincipal=999.970000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=16.740000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[]], RightDetailBaseModel[version=0,lastRightMemberNo=5a72a945a48a11e99c8e1ac1b181ecad,lastRightMemberType=1,rightStatus=1,valueDate=Sat Feb 23 00:00:00 CST 2030,dueDate=Sat Mar 23 00:00:00 CST 2030,mustPayDate=Sat Mar 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Tue Mar 26 00:00:00 CST 2030,overdueDay=0,compensationType=1,compensationDate=Sat Mar 23 00:00:00 CST 2030,rightNo=f0fa7d0c6d274b1daf03abe76c8ea882,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,currentStage=3,mustPayPrincipal=1008.320000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=8.400000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[]], RightDetailBaseModel[version=0,lastRightMemberNo=4bfbe1bd2fee4513a0aa3df699fb679c,lastRightMemberType=1,rightStatus=1,valueDate=Wed Jan 23 00:00:00 CST 2030,dueDate=Sat Feb 23 00:00:00 CST 2030,mustPayDate=Sat Feb 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Sat Feb 23 00:00:00 CST 2030,overdueDay=0,compensationType=0,compensationDate=<null>,rightNo=61558d320ff94911a9688cbbe78a7b73,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,currentStage=2,mustPayPrincipal=0.000000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=0.000000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=ACCOUNT_MANAGE_FEE,mustPayAmount=17.1,actualPayAmount=0,derateAmount=0]]], RightDetailBaseModel[version=0,lastRightMemberNo=4bfbe1bd2fee4513a0aa3df699fb679c,lastRightMemberType=1,rightStatus=1,valueDate=Sat Feb 23 00:00:00 CST 2030,dueDate=Sat Mar 23 00:00:00 CST 2030,mustPayDate=Sat Mar 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Sat Mar 23 00:00:00 CST 2030,overdueDay=0,compensationType=0,compensationDate=<null>,rightNo=828df62153554fdeac94332042119d49,repurchasedFeeList=[],interestMargin=0.000000,interestCost=0.000000,currentStage=3,mustPayPrincipal=0.000000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=0.000000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=ACCOUNT_MANAGE_FEE,mustPayAmount=17.1,actualPayAmount=0,derateAmount=0]]]],allDebitList=[DebitDetailBaseModel[version=0,lastDebitMemberNo=1a16a209acf711e9a3aefa163fdb847b,lastDebitMemberType=2,debitStatus=1,valueDate=Wed Jan 23 00:00:00 CST 2030,dueDate=Sat Feb 23 00:00:00 CST 2030,mustPayDate=Sat Feb 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Sat Feb 23 00:00:00 CST 2030,overdueDay=0,debitNo=6e140db1e7d145c19a589743531b1459,currentStage=2,mustPayPrincipal=999.970000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=16.740000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=ACCOUNT_MANAGE_FEE,mustPayAmount=17.1,actualPayAmount=0,derateAmount=0]]], DebitDetailBaseModel[version=0,lastDebitMemberNo=1a16a209acf711e9a3aefa163fdb847b,lastDebitMemberType=2,debitStatus=1,valueDate=Sat Feb 23 00:00:00 CST 2030,dueDate=Sat Mar 23 00:00:00 CST 2030,mustPayDate=Sat Mar 23 00:00:00 CST 2030,actualPayDate=<null>,graceDate=Sat Mar 23 00:00:00 CST 2030,overdueDay=0,debitNo=32dc9ff1dda447b8a874c821cb46ce20,currentStage=3,mustPayPrincipal=1008.320000,actualPayPrincipal=0.000000,deratePrincipal=0.000000,mustPayInterest=8.400000,actualPayInterest=0.000000,derateInterest=0.000000,mustPayPenaltyInterest=0.000000,actualPayPenaltyInterest=0.000000,deratePenaltyInterest=0.000000,feeDetailList=[FeeModel[feeCode=ACCOUNT_MANAGE_FEE,mustPayAmount=17.1,actualPayAmount=0,derateAmount=0]]]],refRepayModelList=[RefRepayModel[capitalCode=C5004,currentStage=1,actualPayPrincipal=2008.290000,actualPayInterest=0.000000,actualPayPenaltyInterest=0.000000,repayDate=Sat Mar 02 00:00:00 CST 2030]]]";
//
//		String classTemp = new PreSettleDebitAndRightRequest().toString();
//		classTemp = classTemp.substring(classTemp.indexOf("[")+1,classTemp.length() -1);
//
//		String[] fieldTemps = classTemp.split(",");
//
//		Map<String,String> dataMap = new HashMap<>();
//
//		for(String fieldTemp : fieldTemps){
//			String[] fstrs = fieldTemp.split("=");
//			Pattern pattern = Pattern.compile(fstrs[0]+"=(\\w| |:|-|\\.|<|>|([\\u4e00-\\u9fa5]))+");
//			Matcher matcher = pattern.matcher(req);
//			while (matcher.find()){
//				String[] strs = matcher.group().split("=");
//				dataMap.put(fstrs[0],"<null>".equals(strs[1].trim())?null:strs[1].trim());
//			}
//		}
//
//		for(String fieldTemp : fieldTemps){
//			String[] fstrs = fieldTemp.split("=");
//			if(!dataMap.containsKey(fstrs[0])){
////				Pattern pattern = Pattern.compile(fstrs[0]+"=\\[(.*)");
////				Matcher matcher = pattern.matcher(req);
////				while (matcher.find()){
////					String[] strs = matcher.group().split("=");
////					dataMap.put(fstrs[0],"<null>".equals(strs[1].trim())?null:strs[1].trim());
////				}
//
//				int startIndex = req.indexOf(fstrs[0]);
//				int endIndex = getClosebracketsIndex(req,"[","]",startIndex);
//				if(endIndex>0) {
//					String listContent = req.substring(startIndex+fstrs[0].length()+2, endIndex);
//					List<Map<String,String>> list = new ArrayList<>();
//					int startSubIndex = 0,endSubIndex = startSubIndex;
//					do{
//						endSubIndex = listContent.length();
//						listContent = listContent.substring(startSubIndex,endSubIndex);
//						startSubIndex = listContent.indexOf("[");
//						if(startSubIndex < 0){
//							break;
//						}
//						endSubIndex = getClosebracketsIndex(listContent,"[","]",startSubIndex);
//						System.out.println(listContent.substring(startSubIndex+1,endSubIndex));
//						startSubIndex = endSubIndex;
//					}while (endSubIndex > 0);
//				}
//			}
//		}
//
//		System.out.println(JSON.toJSONString(dataMap));
//	}


    public static String getClosebracketsContent(String str){
        String openCh = "[";
        String closeCh = "]";
        Stack<String> stack = new Stack<>();
        boolean startMap = false;
        int startIndex = -1;
        int endIndex = -1;
        for(int i = 0;i<str.length();i++){
            if(openCh.equals(str.substring(i,i+1))){
                stack.push(openCh);
                if(!startMap){
                    startIndex = i;
                }
                startMap = true;
            }else if(closeCh.equals(str.substring(i,i+1))){
                if(!stack.isEmpty()){
                    stack.pop();
                }
            }
            if(stack.isEmpty() && startMap){
                endIndex = i;
                break;
            }
        }
        if(startIndex < 0 || endIndex<0){
            return "";
        }

        return str.substring(startIndex+1,endIndex);
    }




}
